<?php

	require_once("../../../inc/conecta.inc.php");
	
	if(isset($_GET['action'])){
		
		if($_GET['action'] == "delete"){
			$excluir = $_POST['excluir'];
			if(!empty($excluir)){
				for($i=0; $i<count($excluir); $i++){
					mysql_query("DELETE FROM `vagas_has_area_profissional` WHERE `vagas_idvagas` = ".$excluir[$i]) or die (mysql_error());
					mysql_query("DELETE FROM `vagas_has_candidato` WHERE `vagas_idvagas` = ".$excluir[$i]) or die (mysql_error());
					mysql_query("DELETE FROM `vagas` WHERE `idvagas` = ".$excluir[$i]) or die (mysql_error());
				}
			}
			header("location: ../../index.php?option=into&view=ofertas");
		}
		
	}else{
	
		if(strtolower($_POST['session']) == 'status'){
			
			$status = $_POST['status'] == 'ico_yes.png' ? 'Liberado' : 'Bloqueado';
			
			mysql_query("UPDATE `vagas` SET `status` = '".$status."' WHERE `idvagas` = ".$_POST['id']);
			
		}else{
			
			$status = $_POST['status'] == 'ico_yes.png' ? 'S' : 'N';
			
			mysql_query("UPDATE `vagas` SET `destaque` = '".$status."' WHERE `idvagas` = ".$_POST['id']);
			
		}
	
	}

?>